<?php
/**
 * Created by 绵阳人维网络科技有限公司.
 * User: 罗东华
 * Date: 2016/3/21
 * Time: 17:09
 */
namespace Home\Controller;
use Common\Controller\LdhC;
class HomeBase extends LdhC{

    public function _initialize(){

        $this->assign('menu',getmenu());

    }
    /**
     * 分页输出
     * @param type $total 信息总数
     * @param type $size 每页数量
     * @param type $number 当前分页号（页码）
     * @param type $config 配置，会覆盖默认设置
     * @return type
     */
    protected function Pages($table, $where=true,$field='',$order=true,$size = 5, $number = 0, $config = array()) {

        $total=M($table)->where($where)->count();
        $Page =page($total, $size, $number, $config);
        $Page->SetPager('default', '<span class="all">共有{recordcount}条信息</span>{first}{prev}{liststart}{list}{listend}{next}{last}');
        $lists = M($table)->field($field)->where($where)->order($order)->limit($Page->firstRow . ',' . $Page->listRows)->select();
        //  echo  M($table)->_sql();exit;
        $this->assign("Page", $Page->show());
        $this->assign("total", $total);

        return $lists;
    }


}